package controller.member;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractCommandController;
import org.springframework.web.servlet.mvc.Controller;
import org.w3c.dom.views.AbstractView;

import Bean.memberBean;
import dao.memberDao;

public class idFindController extends AbstractCommandController{
	private memberDao dao;
	public void setDao(memberDao dao){
		this.dao = dao;
	}

	@Override
	protected ModelAndView handle(HttpServletRequest arg0,
			HttpServletResponse arg1, Object arg2, BindException arg3)
			throws Exception {
	
		memberBean bean = (memberBean) arg2;
		
		ModelAndView mav = new ModelAndView();
		
		if(bean.getMname() == "" || bean.getMssn1() == "" || bean.getMssn2() == ""){
			mav.setViewName("idFind");
			return mav;
		}
		
		memberBean mBeanId = dao.mFindId(bean);

		if(mBeanId == null){
			mav.setViewName("idFind");
			return mav;
		}

		if(bean.getMname().equals(mBeanId.getMname()) && bean.getMssn1().equals(mBeanId.getMssn1()) && bean.getMssn2().equals(mBeanId.getMssn2())){
			mav.addObject("mBeanId", mBeanId);
			mav.setViewName("idFind");
			return mav;
		}
		
		mav.setViewName("idFind");
		return mav;
	}	
}
